package com.itheima.tcp2;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/*
接收 客户端的数据
并给 客户端 发送数据

 */
public class Server {

    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(1314);
        Socket accept = ss.accept();
        InputStream is = accept.getInputStream();
        int b;
        while ((b=is.read())!=-1){
            System.out.print((char)b);
        }
        //is.close();

        // 获取输出流
        OutputStream os = accept.getOutputStream();
        os.write("hi".getBytes());
        //告诉客户端 我的数据结束了
        accept.shutdownOutput();
        //os.close();
        ss.close();

    }
}
